﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Medicine.Service;
using Medicine.Entity;
namespace Medicine
{
    public partial class UpdateUser : Form
    {
        private UserService us = new UserService();
        private User user;
        public UpdateUser(User user)
        {
            this.user = user;
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            UserForm.uf.Show();
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String name = textBox1.Text.Trim();
            String passwd = textBox2.Text.Trim();

            DialogResult result = MessageBox.Show("确定修改信息？", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (result == DialogResult.OK)
            {

                //确定按钮的方法

               if(!name.Equals("")) this.user.Name = name;
               if (!passwd.Equals("")) this.user.Passwd = passwd;
                us.updateInfo(this.user);
                // UserForm.uf.Hide();
                UserForm.uf.reflush();
                this.Close();
            }
            else
            {

                UserForm.uf.Show();
                this.Close();
      
                //取消按钮的方法
            }

        }
    }
}
